<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>添加添加最美警星</title>
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/animate.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/style.min.css?v=4.0.0" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/toastr/toastr.min.css" rel="stylesheet">
	<link href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>

<body >


	<div class="ibox-content">

		<form id="subForm" method="post" class="form-horizontal"
			onsubmit="return addStarJson()">
			<input type="hidden" name="starId" value="${star.starId}" />
			<input type="hidden" name="imageUrl" value="${star.imageUrl}" />
			<div class="form-group">
				<label class="col-sm-2 control-label">荣誉称号：</label>
				<div class="col-sm-10">
					<input type="text" name="title" placeholder="请输入荣誉称号"
						class="form-control" required="" value="${star.title}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">警星名称：</label>
				<div class="col-sm-10">
					<input type="text" name="name" placeholder="请输入获奖警星人名称"
						class="form-control" required=""  value="${star.name}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">上传人物照片：</label>
				<div class="col-sm-10">
					<div id="imgdiv_1">
						<img id="imgShow_1" name="imageUrl" width="300" height="200" src="${star.imageUrl}"
							style="cursor: pointer;" onclick="clickImg('up_img_1', 'imgShow_1', 800);" />
					</div>
					<input type="hidden" id="up_img_1" name="image" />
				</div>
			</div>
			
			<div class="hr-line-dashed"></div>
			<div class="form-group">
				<div class="col-sm-3 col-sm-offset-9">
					<button class="btn btn-primary" type="submit">保存内容</button>
					<button class="btn btn-white" onclick="clearForm();">清空</button>
				</div>
			</div>

		</form>

	</div>

	</div>

	<script src="<%=request.getContextPath()%>/views/sysdefault/js/jquery.min.js?v=2.1.4"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/content.min.js?v=1.0.0"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/toastr/toastr.min.js"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/layer/layer.js"></script>
    <script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/iCheck/icheck.min.js"></script>
	<script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    
    
    <script type="text/javascript">
    
    var basePath = '<%=request.getContextPath()%>';
    
    toastr.options = {
  		  "closeButton": true,
  		  "debug": false,
  		  "progressBar": true,
  		  "positionClass": "toast-top-left",
  		  "showDuration": "400",
  		  "hideDuration": "1000",
  		  "timeOut": "3000",
  		  "extendedTimeOut": "1000",
  		  "showEasing": "swing",
  		  "hideEasing": "linear",
  		  "showMethod": "fadeIn",
  		  "hideMethod": "fadeOut"
  		}
    //初始化页面
	$(function() {

		
		//新闻封面图片回显
		var imageInfo = $("#imageInfo").val();
		if (imageInfo != '') {
			$("#imgShow_1").attr("src", imageInfo);
			$("#up_img_1").val(imageInfo);
		}

		$(".i-checks").iCheck({
			checkboxClass : "icheckbox_square-green",
			radioClass : "iradio_square-green",
		});

		new uploadPreview({
			UpBtn : "up_img_1",
			DivShow : "imgdiv_1",
			ImgShow : "imgShow_1"
		});
		
		new uploadPreview({
			UpBtn : "up_img_6",
			DivShow : "imgdiv_6",
			ImgShow : "imgShow_6"
		});
		
		new uploadPreview({
			UpBtn : "up_img_7",
			DivShow : "imgdiv_7",
			ImgShow : "imgShow_7"
		});

		//禁止后退键 作用于Firefox、Opera
	    document.onkeypress=banBackSpace;
	    //禁止后退键  作用于IE、Chrome
	    document.onkeydown=banBackSpace;
	});
    var clickImg = function(mInputId, mImgId, imgageCompress) {
		inputId = mInputId;
    	imgId = mImgId;
    	 layer.open({
			  type: 2,
			  title:"上传图片",
			  fix: false, //不固定
			  maxmin: false,
			  shadeClose: true,
			  shade: 0.3,
			  area: ['600px', '430px'],
			  content: basePath + '/common/selectImage.dop?imageCompress='+imgageCompress
			}); 
	}
   //弹出框选择回调函数
	var selectCallBack2 = function(data){
		debugger;
		var obj = jQuery.parseJSON(data);
		var imgList = obj.image.split(',');
		if(imgList.length > 0){
			$("#" + inputId).val(imgList[0]);
			$("#" + imgId).attr("src" , imgList[0]);
		}
		layer.closeAll();
    }
    //提交添加
    var addStarJson = function(){
    	
    	
    	var index;
    	
    	$.ajax({
			type : "POST",
			url : basePath + "/bgPortGlutStar/addStar.do",
			data : $("#subForm").serialize(),
			dataType : "json",
			success : function(msg) { 
				if (msg.errCode == '1') {
					parent.layerCallBack('1');
				}else{
					toastr.error(msg.errMsg, "提示");
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				toastr.error("系统出错！", "提示");
			},
			beforeSend : function(XMLHttpRequest){
				index = layer.load(0, {
					  shade: [0.3,'#ccc'] //0.1透明度的白色背景
					});
			},
			complete : function(XMLHttpRequest, textStatus){
				layer.close(index);
			}
		});
	
		return false;
    }
    
    </script>
    
</body>

</html>